<template>
  <div>
    <div class="source-container page-container">
      <div class="top flex-between">
        <div class="title">Aggregated Data Sour</div>
        <el-input
          placeholder="Search"
          v-model="searchValue"
          class="input-search"
          clearable
          @keyup.enter.native="handleSearch"
        >
          <el-button slot="append" icon="el-icon-search" @click="handleSearch"></el-button>
        </el-input>
      </div>
      <div class="bottom">
        <el-table :data="tableData" header-row-class-name="tabletitle" stripe>
          <el-table-column prop="databaseOrSource" label="Database or Source" width="330">
          </el-table-column>
          <el-table-column prop="dencryption" label="Dencryption"> </el-table-column>
          <el-table-column prop="link" label="Link" width="230">
            <template slot-scope="scope">
              <div class="flex-center-start" @click="goDetail(scope)">
                <div class="link-icon"></div>
                <div class="link">{{scope.row.link}}</div>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <Pagination
          :pageNo="pageNo"
          :total="total"
          :pageSize="pageSize"
          @handleCurrentChange="handleCurrentChange"
        />
      </div>
    </div>
  </div>
</template>

<script>
import Pagination from "@/components/Pagination.vue";
export default {
  components: {
    Pagination,
  },
  data() {
    return {
      pageNo: 1, // 分页
      total: 0,
      pageSize: 10,
      searchValue: "",
      tableData: [
      ],
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      this.$api
        .getAggDataSource({
          pageNo: this.pageNo,
          pageSize: this.pageSize,
          search: this.searchValue,
        })
        .then((res) => {
          this.tableData = res.list
          this.total = res.total
        });
    },
    handleSearch(){
      // 搜索
      this.getData();
    },
    handleCurrentChange(data) {
      this.pageNo = data;
    },
    goDetail(scope){
      window.open("http://" + scope.row.link)
    }
  },
};
</script>

<style lang="scss" scoped>
.page-container {
  margin: 0 auto;
  margin-top: 24px;
  margin-bottom: 140px;
  width: 1340px;
  background: #ffffff;
  border-radius: 2px 2px 0px 0px;
  overflow: hidden;
  &.source-container {
    // display: inline-block;
    padding: 0 16px;
  }
}
.source-container {
  .top {
    margin: 0 auto;
    height: 70px;
    padding: 0px 16px;
    .title {
      padding-top: 20px;
      padding-bottom: 10px;
      font-size: 20px;
      font-weight: bold;
      color: #17233d;
      line-height: 24px;
    }
    ::v-deep .input-search {
      width: 400px;
      margin-right: 30px;
      .el-input-group__append {
        background: linear-gradient(270deg, #8853ff 0%, #5564fe 100%);
        color: white;
        border: none;
      }
    }
  }
  ::v-deep .el-table {
    .tabletitle {
      background: #f3efff;
      .el-table__cell {
        background: transparent;
        font-family: Helvetica-Bold, Helvetica;
        font-weight: bold;
        color: #17233d;
        line-height: 22px;
      }
    }
    .link-icon {
      width: 17px;
      height: 16px;
      background-image: url(~@/assets/img/icon_link.png);
      background-repeat: no-repeat;
      background-size: 100% 100%;
      background-position: center;
    }
    .link {
      cursor: pointer;
      color: #6e5bfe;
    }
  }
}
// 响应式设计

@media screen and (max-width: 768px) {
  ::v-deep .source-container {
    width: 100%;
    .top {
      padding: 0;
      flex-direction: column;
      height: auto;
      margin-bottom: 20px;
      .input-search {
        width: 100%;
        margin-right: 0px;
      }
    }
  }
}
</style>
